<!doctype html>














<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="en" 
  
>
  <!-- The Head -->

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="theme-color" media="(prefers-color-scheme: light)" content="#f7f7f7">
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1b1b1e">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta
    name="viewport"
    content="width=device-width, user-scalable=no initial-scale=1, shrink-to-fit=no, viewport-fit=cover"
  >

  

  

  
    <!-- Begin Jekyll SEO tag v2.8.0 -->
<meta name="generator" content="Jekyll v4.3.2" />
<meta property="og:title" content="High Performance OS - shanango" />
<meta name="author" content="Chunsheng Luo" />
<meta property="og:locale" content="en" />
<meta name="description" content="一、论序" />
<meta property="og:description" content="一、论序" />
<link rel="canonical" href="https://luochenglcs.github.io/posts/High-Performance-OS-shanango/" />
<meta property="og:url" content="https://luochenglcs.github.io/posts/High-Performance-OS-shanango/" />
<meta property="og:site_name" content="Cheng Luo" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-10-14T00:00:00+00:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="High Performance OS - shanango" />
<meta name="twitter:site" content="@luochenglcs" />
<meta name="twitter:creator" content="@Chunsheng Luo" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"Chunsheng Luo","url":"https://github.com/luochenglcs"},"dateModified":"2023-08-03T12:09:49+00:00","datePublished":"2021-10-14T00:00:00+00:00","description":"一、论序","headline":"High Performance OS - shanango","mainEntityOfPage":{"@type":"WebPage","@id":"https://luochenglcs.github.io/posts/High-Performance-OS-shanango/"},"url":"https://luochenglcs.github.io/posts/High-Performance-OS-shanango/"}</script>
<!-- End Jekyll SEO tag -->

  

  <title>High Performance OS - shanango | Cheng Luo
  </title>

  <!--
  The Favicons for Web, Android, Microsoft, and iOS (iPhone and iPad) Apps
  Generated by: https://realfavicongenerator.net/
-->



<link rel="apple-touch-icon" sizes="180x180" href="/assets/img/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicons/favicon-16x16.png">
<link rel="manifest" href="/assets/img/favicons/site.webmanifest">
<link rel="shortcut icon" href="/assets/img/favicons/favicon.ico">
<meta name="apple-mobile-web-app-title" content="Cheng Luo">
<meta name="application-name" content="Cheng Luo">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/assets/img/favicons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">


  
    
      <link rel="preconnect" href="https://fonts.googleapis.com" >
      <link rel="dns-prefetch" href="https://fonts.googleapis.com" >
    
      <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
      <link rel="dns-prefetch" href="https://fonts.gstatic.com" crossorigin>
    
      <link rel="preconnect" href="https://fonts.googleapis.com" >
      <link rel="dns-prefetch" href="https://fonts.googleapis.com" >
    
      <link rel="preconnect" href="https://cdn.jsdelivr.net" >
      <link rel="dns-prefetch" href="https://cdn.jsdelivr.net" >
    

    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lato&family=Source+Sans+Pro:wght@400;600;700;900&display=swap">
  

  <!-- GA -->
  

  <!-- Bootstrap -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">

  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.4.0/css/all.min.css">

  <link rel="stylesheet" href="/assets/css/style.css">

  
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tocbot@4.21.0/dist/tocbot.min.css">
  

  
    <!-- Manific Popup -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/magnific-popup@1.1.0/dist/magnific-popup.min.css">
  

  <!-- JavaScript -->

  
    <!-- Switch the mode between dark and light. -->

<script type="text/javascript">
  class ModeToggle {
    static get MODE_KEY() {
      return 'mode';
    }
    static get MODE_ATTR() {
      return 'data-mode';
    }
    static get DARK_MODE() {
      return 'dark';
    }
    static get LIGHT_MODE() {
      return 'light';
    }
    static get ID() {
      return 'mode-toggle';
    }

    constructor() {
      if (this.hasMode) {
        if (this.isDarkMode) {
          if (!this.isSysDarkPrefer) {
            this.setDark();
          }
        } else {
          if (this.isSysDarkPrefer) {
            this.setLight();
          }
        }
      }

      let self = this;

      /* always follow the system prefers */
      this.sysDarkPrefers.addEventListener('change', () => {
        if (self.hasMode) {
          if (self.isDarkMode) {
            if (!self.isSysDarkPrefer) {
              self.setDark();
            }
          } else {
            if (self.isSysDarkPrefer) {
              self.setLight();
            }
          }

          self.clearMode();
        }

        self.notify();
      });
    } /* constructor() */

    get sysDarkPrefers() {
      return window.matchMedia('(prefers-color-scheme: dark)');
    }

    get isSysDarkPrefer() {
      return this.sysDarkPrefers.matches;
    }

    get isDarkMode() {
      return this.mode === ModeToggle.DARK_MODE;
    }

    get isLightMode() {
      return this.mode === ModeToggle.LIGHT_MODE;
    }

    get hasMode() {
      return this.mode != null;
    }

    get mode() {
      return sessionStorage.getItem(ModeToggle.MODE_KEY);
    }

    /* get the current mode on screen */
    get modeStatus() {
      if (this.isDarkMode || (!this.hasMode && this.isSysDarkPrefer)) {
        return ModeToggle.DARK_MODE;
      } else {
        return ModeToggle.LIGHT_MODE;
      }
    }

    setDark() {
      document.documentElement.setAttribute(ModeToggle.MODE_ATTR, ModeToggle.DARK_MODE);
      sessionStorage.setItem(ModeToggle.MODE_KEY, ModeToggle.DARK_MODE);
    }

    setLight() {
      document.documentElement.setAttribute(ModeToggle.MODE_ATTR, ModeToggle.LIGHT_MODE);
      sessionStorage.setItem(ModeToggle.MODE_KEY, ModeToggle.LIGHT_MODE);
    }

    clearMode() {
      document.documentElement.removeAttribute(ModeToggle.MODE_ATTR);
      sessionStorage.removeItem(ModeToggle.MODE_KEY);
    }

    /* Notify another plugins that the theme mode has changed */
    notify() {
      window.postMessage(
        {
          direction: ModeToggle.ID,
          message: this.modeStatus
        },
        '*'
      );
    }

    flipMode() {
      if (this.hasMode) {
        if (this.isSysDarkPrefer) {
          if (this.isLightMode) {
            this.clearMode();
          } else {
            this.setLight();
          }
        } else {
          if (this.isDarkMode) {
            this.clearMode();
          } else {
            this.setDark();
          }
        }
      } else {
        if (this.isSysDarkPrefer) {
          this.setLight();
        } else {
          this.setDark();
        }
      }

      this.notify();
    } /* flipMode() */
  } /* ModeToggle */

  const modeToggle = new ModeToggle();
</script>

  

  <!-- A placeholder to allow defining custom metadata -->

</head>


  <body>
    <!-- The Side Bar -->

<div id="sidebar" class="d-flex flex-column align-items-end">
  <div class="profile-wrapper">
    <a href="/" id="avatar" class="rounded-circle">
      
        
        <img src="/assets/img/favicons/android-chrome-512x512.png" width="112" height="112" alt="avatar" onerror="this.style.display='none'">
      
    </a>

    <div class="site-title">
      <a href="/">Cheng Luo</a>
    </div>
    <div class="site-subtitle fst-italic">Linux operating system engineer</div>
  </div>
  <!-- .profile-wrapper -->

  <ul class="nav flex-column flex-grow-1 w-100 ps-0">
    <!-- home -->
    <li class="nav-item">
      <a href="/" class="nav-link">
        <i class="fa-fw fas fa-home"></i>
        <span>HOME</span>
      </a>
    </li>
    <!-- the real tabs -->
    
      <li class="nav-item">
        <a href="/categories/" class="nav-link">
          <i class="fa-fw fas fa-stream"></i>
          

          <span>CATEGORIES</span>
        </a>
      </li>
      <!-- .nav-item -->
    
      <li class="nav-item">
        <a href="/tags/" class="nav-link">
          <i class="fa-fw fas fa-tags"></i>
          

          <span>TAGS</span>
        </a>
      </li>
      <!-- .nav-item -->
    
      <li class="nav-item">
        <a href="/archives/" class="nav-link">
          <i class="fa-fw fas fa-archive"></i>
          

          <span>ARCHIVES</span>
        </a>
      </li>
      <!-- .nav-item -->
    
      <li class="nav-item">
        <a href="/about/" class="nav-link">
          <i class="fa-fw fas fa-info-circle"></i>
          

          <span>ABOUT</span>
        </a>
      </li>
      <!-- .nav-item -->
    
  </ul>
  <!-- ul.nav.flex-column -->

  <div class="sidebar-bottom d-flex flex-wrap  align-items-center w-100">
    
      <button class="mode-toggle btn" aria-label="Switch Mode">
        <i class="fas fa-adjust"></i>
      </button>

      
        <span class="icon-border"></span>
      
    

    
      

      
        <a
          href="https://github.com/luochenglcs"
          aria-label="github"
          

          
            target="_blank"
            
          

          

          
            rel="noopener noreferrer"
          
        >
          <i class="fab fa-github"></i>
        </a>
      
    
      

      
    
      

      
        <a
          href="javascript:location.href = 'mailto:' + ['luochunsheng','ustc.edu'].join('@')"
          aria-label="email"
          

          

          

          
        >
          <i class="fas fa-envelope"></i>
        </a>
      
    
  </div>
  <!-- .sidebar-bottom -->
</div>
<!-- #sidebar -->


    <div id="main-wrapper" class="d-flex justify-content-center">
      <div id="main" class="container px-xxl-5">
        <!-- The Top Bar -->

<div id="topbar-wrapper">
  <div
    id="topbar"
    class="container d-flex align-items-center justify-content-between h-100"
  >
    <span id="breadcrumb">
      

      
        
          
            <span>
              <a href="/">
                Home
              </a>
            </span>

          
        
          
        
          
            
              <span>High Performance OS - shanango</span>
            

          
        
      
    </span>
    <!-- endof #breadcrumb -->

    <i id="sidebar-trigger" class="fas fa-bars fa-fw"></i>

    <div id="topbar-title">
      Post
    </div>

    <i id="search-trigger" class="fas fa-search fa-fw"></i>
    <span id="search-wrapper" class="align-items-center">
      <i class="fas fa-search fa-fw"></i>
      <input
        class="form-control"
        id="search-input"
        type="search"
        aria-label="search"
        autocomplete="off"
        placeholder="Search..."
      >
    </span>
    <span id="search-cancel">Cancel</span>
  </div>
</div>

        











<div class="row">
  <!-- core -->
  <div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pe-xl-4">
    

    <div class="post px-1 px-md-2">
      

      
        
      
        <!-- Refactor the HTML structure -->



<!--
  In order to allow a wide table to scroll horizontally,
  we suround the markdown table with `<div class="table-wrapper">` and `</div>`
-->



<!--
  Fixed kramdown code highlight rendering:
  https://github.com/penibelst/jekyll-compress-html/issues/101
  https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
-->



<!-- Change the icon of checkbox -->


<!-- images -->




<!-- Add header for code snippets -->



<!-- Create heading anchors -->





  
  

  

  
  

  
    
    

    
      
        
        
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    

    

  

  
  

  
    
    

    
      
        
        
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    
      

      
      

      
      
      

      

    

    

  

  
  

  




<!-- return -->




<h1 data-toc-skip>High Performance OS - shanango</h1>

<div class="post-meta text-muted">
    <!-- published date -->
    <span>
      Posted
      <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class=""
  data-ts="1634169600"
  data-df="ll"
  
    data-bs-toggle="tooltip" data-bs-placement="bottom"
  
>
  Oct 14, 2021
</em>

    </span>

    <!-- lastmod date -->
    
    <span>
      Updated
      <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class=""
  data-ts="1691064589"
  data-df="ll"
  
    data-bs-toggle="tooltip" data-bs-placement="bottom"
  
>
  Aug  3, 2023
</em>

    </span>
    

  

  <div class="d-flex justify-content-between">
    <!-- author(s) -->
    <span>
      

      By

      <em>
      
        
          <a href="https://github.com/luochenglcs">Chunsheng Luo</a>
          
        
      
      </em>
    </span>

    <div>
      <!-- read time -->
      <!-- Calculate the post's reading time, and display the word count in tooltip -->



<!-- words per minute -->










<!-- return element -->
<span
  class="readtime"
  data-bs-toggle="tooltip"
  data-bs-placement="bottom"
  title="2742 words"
>
  <em>15 min</em> read</span>

    </div>

  </div> <!-- .d-flex -->

</div> <!-- .post-meta -->
<div class="post-content">
  <h3 id="一论序"><span class="me-2">一、论序</span><a href="#一论序" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
</pre></td><td class="rouge-code"><pre><span class="n">Shenango</span>  <span class="n">Achieving</span> <span class="n">High</span> <span class="n">CPU</span> <span class="n">Efficiency</span> <span class="k">for</span> <span class="n">latency</span><span class="o">-</span><span class="n">sensitive</span> <span class="n">dc</span> <span class="n">workloads</span><span class="p">.</span><span class="n">pdf</span> <span class="p">(</span><span class="mi">526</span><span class="p">.</span><span class="mi">36</span><span class="n">KB</span><span class="p">)</span>
<span class="n">https</span><span class="o">:</span><span class="c1">//github.com/shenango/shenango</span>

<span class="n">IX</span> <span class="n">A</span> <span class="n">Protected</span> <span class="n">Dataplane</span> <span class="n">Operating</span> <span class="n">System</span> <span class="k">for</span> <span class="n">High</span> <span class="n">Throughput</span> <span class="n">and</span> <span class="n">Low</span> <span class="n">Latency</span><span class="p">.</span><span class="n">pdf</span> <span class="p">(</span><span class="mi">2</span><span class="p">.</span><span class="mi">28</span><span class="n">MB</span><span class="p">)</span>
<span class="n">The</span> <span class="n">IX</span> <span class="n">Operating</span> <span class="n">System</span> <span class="n">Combining</span> <span class="n">Low</span> <span class="n">Latency</span><span class="p">,</span> <span class="n">High</span> <span class="n">Throughput</span><span class="p">,</span> <span class="n">and</span> <span class="n">efficiency</span> <span class="n">in</span> <span class="n">a</span> <span class="n">protected</span> <span class="n">dataplane</span><span class="p">.</span><span class="n">pdf</span> <span class="p">(</span><span class="mi">1</span><span class="p">.</span><span class="mi">18</span><span class="n">MB</span><span class="p">)</span>
<span class="n">IX</span>  <span class="n">A</span> <span class="n">Protected</span> <span class="n">Dataplane</span> <span class="n">Operating</span> <span class="n">System</span> <span class="k">for</span> <span class="n">High</span> <span class="n">Throughput</span> <span class="n">and</span> <span class="n">Low</span> <span class="n">Latency</span><span class="p">.</span><span class="n">pdf</span> <span class="p">(</span><span class="mi">371</span><span class="p">.</span><span class="mi">23</span><span class="n">KB</span><span class="p">)</span>
<span class="n">https</span><span class="o">:</span><span class="c1">//github.com/ix-project/ix</span>

<span class="n">ZygOS</span> <span class="n">Achieving</span> <span class="n">Low</span> <span class="n">Tail</span> <span class="n">Latency</span> <span class="k">for</span> <span class="n">microsecond</span><span class="o">-</span><span class="n">scale</span> <span class="n">networked</span> <span class="n">tasks</span><span class="p">.</span><span class="n">pdf</span> <span class="p">(</span><span class="mi">694</span><span class="p">.</span><span class="mi">61</span><span class="n">KB</span><span class="p">)</span>
</pre></td></tr></tbody></table></code></div></div>

<h3 id="二shenango"><span class="me-2">二、shenango</span><a href="#二shenango" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
</pre></td><td class="rouge-code"><pre><span class="nl">https:</span><span class="c1">//zhuanlan.zhihu.com/p/360075148 知乎谬赞shenango</span>

<span class="n">https</span><span class="o">:</span><span class="c1">//tongtianta.site/paper/68031 论文中英翻译</span>

<span class="n">https</span><span class="o">:</span><span class="c1">//nan01ab.github.io/2019/03/Shinjuku-and-Shenango.html  Shinjuku and Shenango, New Network Stack and Optimizations</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="rouge-code"><pre><span class="c1">//基本介绍	</span>
	<span class="n">Shenango</span><span class="err">核心的重新分配的目的是为了给应用尽可能分配少的</span><span class="n">CPU</span><span class="err">核心，但是有不至于导致</span><span class="n">compute</span> <span class="n">congestion</span><span class="err">的现象。</span>
    <span class="n">Shenango</span><span class="err">同时考虑线程和</span><span class="n">packet</span><span class="err">来探测</span><span class="n">compute</span> <span class="n">congestion</span><span class="err">的信号，另外引入一个</span><span class="n">congestion</span> <span class="n">detection</span> <span class="n">algorithm</span><span class="err">来探明一个应用是否能从分配更多的核心中受益。这个算法要求细粒度的，高频率的观察每个应用的线程和</span><span class="n">packet</span><span class="err">排队情况。</span> <span class="err">所以这里</span><span class="n">Shenango</span><span class="err">引入了一个</span><span class="n">IOKernel</span><span class="err">，</span><span class="n">IOKernel</span><span class="err">指定一个核心运行的、忙轮询的进程，</span><span class="n">IOKernel</span><span class="err">运行在特权态。</span><span class="n">IOKernel</span><span class="err">通过忙轮询的方式在微秒级别的粒度观察观察每个应用的线程和</span><span class="n">packet</span><span class="err">排队情况。</span>
	<span class="mi">1</span> <span class="n">Shenango</span><span class="err">引入了一种</span><span class="n">packet</span> <span class="n">steering</span><span class="err">机制。通过使用</span><span class="n">packet</span> <span class="n">steering</span> <span class="n">rules</span><span class="err">机制来快速实现核心的重新分配。</span>
	<span class="mi">2</span> <span class="err">应用运行在一个</span><span class="n">runtime</span><span class="err">中，通过共享内存和</span><span class="n">IOKernel</span><span class="err">交互。在应用启动的时候，</span><span class="n">runtime</span><span class="err">会创建多个内核线程</span><span class="p">(</span><span class="n">pthread</span><span class="p">)</span><span class="err">，每个内核线程有一个本地的</span><span class="n">runqueue</span><span class="err">。应用的逻辑使用一些保存在这些</span><span class="n">runqueue</span><span class="err">中的轻量级的用户基本的线程来运行。不同核心之间的负载均衡通过任务窃取的方式来处理。这里与</span><span class="n">go</span> <span class="n">runtime</span><span class="err">有些类似，不过没有</span><span class="n">IOKernel</span><span class="err">，用户态线程这里称之为</span><span class="n">uthread</span><span class="err">，而内核态线程称之为</span><span class="n">kthread</span><span class="err">。</span>
    
<span class="c1">//IOKernel	</span>
	<span class="n">IOKernel</span><span class="err">组件运行在一个指定的核心上面，主要的作用有两个，一个是决定一个应用需要分配多少的</span><span class="n">CPU</span><span class="err">核心，要分配的话分配那一个</span><span class="n">CPU</span><span class="err">核心；另外一个就是</span><span class="n">Bypass</span> <span class="n">Kernel</span><span class="err">的方式处理所有的网络</span><span class="n">IO</span><span class="err">。它通过忙轮询的方式直接轮询</span><span class="n">NIC</span><span class="err">的接受队列，然后将收到的数据包。由于</span><span class="n">IOKernel</span><span class="err">既要处理</span><span class="n">CPU</span><span class="err">核心的分配，又要处理网络数据包的转发，所以</span><span class="n">CPU</span><span class="err">核心的分配必须处理得很快，否则会降低数据处理的性能。</span>

 	<span class="mi">1</span> <span class="err">每个应用会有</span><span class="n">guaranteed</span> <span class="n">cores</span><span class="err">以及</span><span class="n">burstable</span> <span class="n">cores</span><span class="err">。前者可以理解为固定分配的，不用担心被抢占，而后者是根据需要分配的。一个</span><span class="n">kthread</span><span class="err">在自己的本地的</span><span class="n">runqueue</span><span class="err">中没有工作可以做的时候，代表这个进程在这个时间段内不需要这么多的</span><span class="n">CPU</span><span class="err">核心。应用会主动让出</span><span class="n">kthread</span><span class="err">，并通知</span><span class="n">IO</span> <span class="n">Kernel</span><span class="err">。</span><span class="n">IOKernel</span><span class="err">可以在任何时候抢占一个</span><span class="n">burstable</span><span class="err">核心。</span>
	<span class="mi">2</span> <span class="err">在一个数据包达到一个应用的时候，如果没有被分配的核心，</span><span class="n">IO</span> <span class="n">Kernel</span><span class="err">会立即分配一个。</span><span class="n">IOKernel</span><span class="err">使用</span><span class="n">congestion</span> <span class="n">detection</span><span class="err">算法。这个计算基于两个元素，排队的线程和排队的</span><span class="n">ingress</span><span class="err">的数据包。任何一个队列中的</span><span class="n">item</span><span class="err">出现在连续的两个</span><span class="n">interval</span><span class="err">的时候，表明这个</span><span class="n">item</span><span class="err">至少排队了</span><span class="mi">5u</span><span class="n">s</span><span class="err">。对于发现可能处理拥塞状态的应用，</span><span class="n">IO</span> <span class="n">Kernel</span><span class="err">会分配额外的核心。这些队列就使用</span><span class="n">ring</span> <span class="n">buffer</span><span class="err">实现。在这之中通过头尾指针就可以其队列中表现出不同的</span><span class="n">interval</span><span class="err">。</span>
	<span class="mi">3</span> <span class="err">在具体分配给那一个核心的时候，</span><span class="n">IOKernel</span><span class="err">主要考虑三个因素。</span><span class="mi">1</span><span class="p">.</span> <span class="n">Hyper</span><span class="o">-</span><span class="n">threading</span> <span class="n">efficiency</span><span class="err">，</span><span class="n">IO</span> <span class="n">Kernel</span><span class="err">趋向于将分配在同一个物理核心的</span><span class="n">HyperThread</span><span class="err">上面，因为这样的缓存局部性更好。</span><span class="mi">2</span><span class="p">.</span> <span class="n">CaChe</span> <span class="n">Locality</span><span class="err">，如果一个应用的数据已经在一个</span><span class="n">CPU</span><span class="err">核心的</span><span class="n">L1</span><span class="o">/</span><span class="n">L2</span><span class="err">中，则</span><span class="n">IOKernel</span><span class="err">会倾向于将其分配到对应的核心上面，</span><span class="mi">3</span><span class="p">.</span> <span class="n">Latency</span><span class="err">，在可能的情况下，肯定是优先选择分配空闲核心而不是忙的核心。</span>
        
	<span class="n">IOKernel</span><span class="err">忙轮询</span><span class="n">NIC</span><span class="err">的收入包队列，和应用的出队列，</span><span class="n">IOKernel</span><span class="err">可以直接将数据包传递给对应的应用。</span><span class="n">Shenango</span><span class="err">中，每个</span><span class="n">runtime</span><span class="err">都会配置自己的</span><span class="n">IP</span><span class="err">地址和</span><span class="n">Mac</span><span class="err">地址。在一个新的数据包达到的时候，通过参看数据包中的</span><span class="n">Mac</span><span class="err">地址即可得知对应的</span><span class="n">runtime</span><span class="err">。</span><span class="n">IOKernel</span><span class="err">通过</span><span class="n">RSS</span><span class="err">的方式在这个</span><span class="n">runtime</span><span class="err">中的</span><span class="n">CPU</span><span class="err">核心之间选择，将数据包放入其</span> <span class="n">ingress</span> <span class="n">packet</span> <span class="n">queue</span><span class="err">。</span><span class="n">engress</span><span class="err">队列也使用，轮询的方式可能导致很多的</span><span class="n">CPU</span><span class="err">占用，由于</span><span class="n">IOKernel</span><span class="err">可知</span><span class="n">kthread</span><span class="err">的活跃情况，它只需要轮询活跃的那一部分即可。</span>
        
<span class="c1">//runtime</span>
	<span class="n">runtime</span><span class="err">在</span><span class="n">IOKernel</span><span class="err">动态分配的</span><span class="n">CPU</span><span class="err">核心上面进行调度操作。在</span><span class="n">runtime</span><span class="err">初始化的时候，它会注册若干的</span><span class="n">kthreads</span><span class="err">到</span><span class="n">IO</span> <span class="n">Kernel</span><span class="err">和对应的共享内存的区域作为</span><span class="n">packet</span> <span class="n">queue</span><span class="err">。在</span><span class="n">IOKernel</span><span class="err">分配一个新的核心的时候，它会唤醒一个对应</span><span class="n">rumtime</span><span class="err">的</span><span class="n">kthread</span><span class="err">，并绑定到指定</span><span class="n">CPU</span><span class="err">核心上面。这个的</span><span class="n">runtime</span><span class="err">的结构是每个</span><span class="kr">thread</span><span class="err">一个队列，并加上</span><span class="n">work</span> <span class="n">stealing</span><span class="err">机制来实现负载均衡。这个和</span><span class="n">GO</span><span class="err">的</span><span class="n">runtime</span><span class="err">类似。</span>
<span class="err">————————————————————————————————————————————</span>
<span class="err">引用：</span><span class="n">https</span><span class="o">:</span><span class="c1">//nan01ab.github.io/2019/03/Shinjuku-and-Shenango.html</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
</pre></td><td class="rouge-code"><pre><span class="n">Shenango</span><span class="err">致力于实现三个目标的系统：</span><span class="mi">1</span><span class="err">）微秒级的端到端延迟和数据中心应用程序的高吞吐量；</span><span class="mi">2</span><span class="err">）多核机器上应用程序的</span><span class="n">CPU</span><span class="err">高效能；</span><span class="mi">3</span><span class="err">）应用程序开发人员的高生产率，由于同步</span><span class="n">I</span><span class="o">/</span><span class="n">O</span><span class="err">和标准编程抽象，例如轻量级线程和阻塞</span><span class="n">TCP</span><span class="err">网络套接字。</span>
<span class="err">————————————————————————————————————————————</span>
<span class="err">引用：</span><span class="n">https</span><span class="o">:</span><span class="c1">//zhuanlan.zhihu.com/p/360075148</span>
</pre></td></tr></tbody></table></code></div></div>

<p>1、Shenango实现cpu的动态分配，提高cpu的利用率。cpu均衡的时间在5us以内，而内核通用的均衡是在ms级。</p>

<p>2、网络bypass kernel， IOKernel通过IP+Mac将数据包转发给对应的应用。</p>

<p>总之、实现CPU高利用率和保持低尾延迟。</p>

<h3 id="三-数据中心应用特性"><span class="me-2">三、 数据中心应用特性</span><a href="#三-数据中心应用特性" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<h4 id="1what-is-datacenter-workloads"><span class="me-2">1、what is Datacenter workloads?</span><a href="#1what-is-datacenter-workloads" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<p>2、具备的特点：</p>

<h3 id="四代码分析"><span class="me-2">四、代码分析</span><a href="#四代码分析" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<h4 id="1iokernel"><span class="me-2">1、iokernel</span><a href="#1iokernel" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
</pre></td><td class="rouge-code"><pre><span class="c1">//iokernel 独立核跑的后面进程</span>
    <span class="c1">//main</span>
    	<span class="o">-&gt;</span> <span class="n">dataplane_loop</span>
    		<span class="o">-&gt;</span> <span class="n">cores_adjust_assignments</span> <span class="c1">//每5us执行一次</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="2runtime"><span class="me-2">2、runtime</span><a href="#2runtime" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
</pre></td><td class="rouge-code"><pre><span class="c1">//runtime 链接时使用</span>
<span class="n">__real_main</span> <span class="n">__wrap_main</span> <span class="c1">//what is? https://blog.csdn.net/gzxb1995/article/details/119880109 包装函数</span>

<span class="n">__wrap_main</span> <span class="c1">//shim/entry.c</span>
    <span class="o">-&gt;</span><span class="n">runtime_init</span> <span class="c1">//runtime/init.c</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="3iokernel和runtime联系--af_unix-socket"><span class="me-2">3、iokernel和runtime联系 – AF_UNIX socket</span><a href="#3iokernel和runtime联系--af_unix-socket" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
</pre></td><td class="rouge-code"><pre><span class="c1">//\0/control/iokernel.sock</span>
<span class="n">ioqueues_register_iokernel</span> <span class="c1">//runtime/ioqueues.c  </span>
</pre></td></tr></tbody></table></code></div></div>

<h3 id="五总结"><span class="me-2">五、总结</span><a href="#五总结" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="err">围绕</span> <span class="err">场景痛点、技术思路、方案细节、有益效果、方案缺陷、借鉴意义等方面完成之前分配论文的材料整理，明天下班前完成。</span>
</pre></td></tr></tbody></table></code></div></div>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="rouge-code"><pre><span class="mi">1</span> <span class="err">场景痛点</span>
    <span class="err">目前数据中心的微妙级延迟的解决方案是</span><span class="n">bypass</span><span class="o">-</span><span class="n">kernel</span><span class="p">,</span><span class="err">但是需要专用的</span><span class="n">cpu</span><span class="err">自旋轮询网卡，在中低负载下，会存在</span><span class="n">cpu</span><span class="err">浪费。</span><span class="n">Shenango</span><span class="err">实现了低延迟，但</span><span class="n">CPU</span><span class="err">使用效率更高。</span>
    
<span class="mi">2</span> <span class="err">技术思路</span>    
	<span class="err">以非常精细的粒度（每</span><span class="mi">5</span><span class="err">µ</span><span class="n">s</span><span class="err">）在应用程序之间重新分配内核，从而使对延迟敏感的应用程序未使用的周期可以处理其他事。它可以通过一种高效的算法来检测应用程序何时从更多的内核中受益，以及一种运行在专用内核上的特权组件，称为</span><span class="n">IOKernel</span><span class="err">，协调内核的重新分配，从而实现如此快速的重新分配速率。</span>
    
<span class="mi">3</span> <span class="err">方案细节</span>
     <span class="n">Shenango</span><span class="err">引入一个</span><span class="n">congestion</span> <span class="n">detection</span> <span class="n">algorithm</span><span class="err">来探明一个应用是否能从分配更多的核心中受益。这个算法要求细粒度的，高频率的观察每个应用的线程和</span><span class="n">packet</span><span class="err">排队情况。</span> <span class="err">所以这里</span><span class="n">Shenango</span><span class="err">引入了一个</span><span class="n">IOKernel</span><span class="err">，</span><span class="n">IOKernel</span><span class="err">指定一个核心运行的、轮询的进程，</span><span class="n">IOKernel</span><span class="err">运行在特权态。</span><span class="n">IOKernel</span><span class="err">通过忙轮询的方式在微秒级别的粒度观察观察每个应用的线程和</span><span class="n">packet</span><span class="err">排队情况。</span>
	<span class="mi">1</span> <span class="n">cpu</span><span class="err">重新分配：引入了一种</span><span class="n">packet</span> <span class="n">steering</span><span class="err">机制。通过使用</span><span class="n">packet</span> <span class="n">steering</span> <span class="n">rules</span><span class="err">机制来快速实现核心的重新分配。</span>
	<span class="mi">2</span> <span class="n">Lightweight</span> <span class="n">Threading</span><span class="err">：运行在一个</span><span class="n">runtime</span><span class="err">中，通过共享内存和</span><span class="n">IOKernel</span><span class="err">交互。在应用启动的时候，</span><span class="n">runtime</span><span class="err">会创建多个内核线程</span><span class="p">(</span><span class="n">pthread</span><span class="p">)</span><span class="err">，每个内核线程有一个本地的</span><span class="n">runqueue</span><span class="err">。应用使用一些保存在这些</span><span class="n">runqueue</span><span class="err">中的轻量级的用户线程来运行。不同核心之间的负载均衡通过任务窃取的方式来处理。</span>
    
<span class="n">IOKernel</span><span class="err">：</span>   
	<span class="n">IOKernel</span><span class="err">组件运行在一个指定的核心上面，主要的作用有两个，一个是决定一个应用需要分配多少的</span><span class="n">CPU</span><span class="err">核心，要分配的话分配那一个</span><span class="n">CPU</span><span class="err">核心；另外一个就是</span><span class="n">Bypass</span> <span class="n">Kernel</span><span class="err">的方式处理所有的网络</span><span class="n">IO</span><span class="err">。它通过忙轮询的方式直接轮询</span><span class="n">NIC</span><span class="err">的接受队列，然后将收到的数据包。由于</span><span class="n">IOKernel</span><span class="err">既要处理</span><span class="n">CPU</span><span class="err">核心的分配，又要处理网络数据包的转发，所以</span><span class="n">CPU</span><span class="err">核心的分配必须处理得很快，否则会降低数据处理的性能。</span>
    
 <span class="n">runtime</span><span class="o">:</span>
    <span class="err">在</span><span class="n">runtime</span><span class="err">初始化之后，一般的</span><span class="n">syscall</span><span class="err">也是可以使用的，但是最好不要使用会</span><span class="n">Blocking</span><span class="err">的</span><span class="n">syscall</span><span class="err">。</span><span class="n">runtime</span><span class="err">在</span><span class="n">IOKernel</span><span class="err">动态分配的</span><span class="n">CPU</span><span class="err">核心上面进行调度操作。在</span><span class="n">runtime</span><span class="err">初始化的时候，它会注册若干的</span><span class="n">kthreads</span><span class="err">到</span><span class="n">IO</span> <span class="n">Kernel</span><span class="err">和对应的共享内存的区域作为</span><span class="n">packet</span> <span class="n">queue</span><span class="err">。在</span><span class="n">IOKernel</span><span class="err">分配一个新的核心的时候，它会唤醒一个对应</span><span class="n">rumtime</span><span class="err">的</span><span class="n">kthread</span><span class="err">，并绑定到指定</span><span class="n">CPU</span><span class="err">核心上面。</span><span class="n">runtime</span><span class="err">使用</span><span class="n">run</span><span class="o">-</span><span class="n">to</span><span class="o">-</span><span class="n">completion</span><span class="err">的机制，可以让一个</span><span class="n">uthread</span><span class="err">一直运行到资源地让出。</span>
        
<span class="mi">4</span> <span class="err">有益效果</span>
<span class="o">+</span><span class="err">───────────</span><span class="o">+</span><span class="err">────────────────────</span><span class="o">+</span><span class="err">────────────────────────</span><span class="o">+</span><span class="err">─────────────────────</span><span class="o">+</span>
<span class="o">|</span> <span class="n">system</span>    <span class="o">|</span> <span class="n">Kernel</span><span class="o">-</span><span class="n">bypass</span> <span class="n">net</span>  <span class="o">|</span> <span class="n">Lightweight</span> <span class="n">Threading</span>  <span class="o">|</span> <span class="n">Balancing</span> <span class="n">Interval</span>  <span class="o">|</span>
<span class="o">+</span><span class="err">───────────</span><span class="o">+</span><span class="err">────────────────────</span><span class="o">+</span><span class="err">────────────────────────</span><span class="o">+</span><span class="err">─────────────────────</span><span class="o">+</span>
<span class="o">|</span> <span class="n">Linux</span>     <span class="o">|</span> <span class="n">N</span>                  <span class="o">|</span> <span class="n">N</span>                      <span class="o">|</span> <span class="mi">4</span><span class="n">ms</span>                 <span class="o">|</span>
<span class="o">|</span> <span class="n">Arachne</span>   <span class="o">|</span> <span class="n">N</span>                  <span class="o">|</span> <span class="n">Y</span>                      <span class="o">|</span> <span class="mi">50</span><span class="n">ms</span>                <span class="o">|</span>
<span class="o">|</span> <span class="n">ZygOS</span>     <span class="o">|</span> <span class="n">Y</span>                  <span class="o">|</span> <span class="n">N</span>                      <span class="o">|</span> <span class="n">N</span><span class="o">/</span><span class="n">A</span>                 <span class="o">|</span>
<span class="o">|</span> <span class="n">Shenango</span>  <span class="o">|</span> <span class="n">Y</span>                  <span class="o">|</span> <span class="n">Y</span>                      <span class="o">|</span> <span class="mi">5u</span><span class="n">s</span>                 <span class="o">|</span>
<span class="o">+</span><span class="err">───────────</span><span class="o">+</span><span class="err">────────────────────</span><span class="o">+</span><span class="err">────────────────────────</span><span class="o">+</span><span class="err">─────────────────────</span><span class="o">+</span>
<span class="err">有比</span><span class="n">Arachne</span><span class="err">较低的</span><span class="n">Balancing</span> <span class="n">Interval</span><span class="err">。</span> 
<span class="n">kernel</span><span class="o">-</span><span class="n">bypass</span> <span class="n">net</span><span class="err">借鉴</span><span class="n">ZygOS</span><span class="err">低延。</span>
    
<span class="mi">5</span> <span class="err">方案缺陷</span>
 <span class="n">runtime</span><span class="err">来实现</span><span class="n">Lightweight</span> <span class="n">Threading</span><span class="p">,</span> <span class="n">hack</span> <span class="n">pthread</span><span class="err">、</span><span class="n">mutex</span><span class="err">、</span><span class="n">sem</span><span class="p">,</span> <span class="err">比较定制。</span>
 <span class="err">系统本身要保证无其他应用和业务进程的干扰。</span><span class="n">cpu</span><span class="err">的动态分配其实就</span><span class="kr">thread</span><span class="err">的分配和绑定。</span>
        
<span class="mi">6</span> <span class="err">借鉴意义</span>
        
    
   
</pre></td></tr></tbody></table></code></div></div>

<h3 id="other补充"><span class="me-2">other、补充</span><a href="#other补充" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h3>

<h4 id="1go-runtime"><span class="me-2">1、go runtime</span><a href="#1go-runtime" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="nl">https:</span><span class="c1">//zhuanlan.zhihu.com/p/95056679  万字长文深入浅出 Golang Runtime</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="2dpdk"><span class="me-2">2、dpdk</span><a href="#2dpdk" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="nl">https:</span><span class="c1">//zhuanlan.zhihu.com/p/272722355 DPDK 分析，原理以及学习路线</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="3arachne"><span class="me-2">3、Arachne</span><a href="#3arachne" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>

<div class="language-c highlighter-rouge"><div class="code-header">
        <span data-label-text="C"><i class="fas fa-code fa-fw small"></i></span>
      <button aria-label="copy" data-title-succeed="Copied!"><i class="far fa-clipboard"></i></button></div><div class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
</pre></td><td class="rouge-code"><pre><span class="nl">https:</span><span class="c1">//nbjl.nankai.edu.cn/2020/0306/c12124a266839/page.htm NBJL 2020论文导读7：Arachne Core Aware Thread Management</span>
</pre></td></tr></tbody></table></code></div></div>

<h4 id="4gc-garbage-collection"><span class="me-2">4、gc Garbage Collection</span><a href="#4gc-garbage-collection" class="anchor text-muted"><i class="fas fa-hashtag"></i></a></h4>


</div>

<div class="post-tail-wrapper text-muted">

  <!-- categories -->
  
  <div class="post-meta mb-3">
    <i class="far fa-folder-open fa-fw me-1"></i>
    
      <a href='/categories/linux/'>linux</a>,
      <a href='/categories/shanango/'>shanango</a>
  </div>
  
  <!-- post.html -->

  <!-- tags -->
  
  <div class="post-tags">
    <i class="fa fa-tags fa-fw me-1"></i>
      
      <a href="/tags/shanango/"
          class="post-tag no-text-decoration" >shanango</a>
      
  </div>
  
  
  <div class="post-tail-bottom
    d-flex justify-content-between align-items-center mt-3 pt-5 pb-2">
    <div class="license-wrapper">

      

        

        This post is licensed under 
        <a href="https://creativecommons.org/licenses/by/4.0/">
          CC BY 4.0
        </a>
         by the author.

      
    </div>

    <!-- Post sharing snippet -->

<div class="share-wrapper">
  <span class="share-label text-muted me-1">Share</span>
  <span class="share-icons">
    
    
    

    
      
      <a
        href="https://twitter.com/intent/tweet?text=High%20Performance%20OS%20-%20shanango%20-%20Cheng%20Luo&url=https%3A%2F%2Fluochenglcs.github.io%2Fposts%2FHigh-Performance-OS-shanango%2F"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        title="Twitter"
        target="_blank"
        rel="noopener"
        aria-label="Twitter"
      >
        <i class="fa-fw fab fa-twitter"></i>
      </a>
    
      
      <a
        href="https://www.facebook.com/sharer/sharer.php?title=High%20Performance%20OS%20-%20shanango%20-%20Cheng%20Luo&u=https%3A%2F%2Fluochenglcs.github.io%2Fposts%2FHigh-Performance-OS-shanango%2F"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        title="Facebook"
        target="_blank"
        rel="noopener"
        aria-label="Facebook"
      >
        <i class="fa-fw fab fa-facebook-square"></i>
      </a>
    
      
      <a
        href="https://t.me/share/url?url=https%3A%2F%2Fluochenglcs.github.io%2Fposts%2FHigh-Performance-OS-shanango%2F&text=High%20Performance%20OS%20-%20shanango%20-%20Cheng%20Luo"
        data-bs-toggle="tooltip"
        data-bs-placement="top"
        title="Telegram"
        target="_blank"
        rel="noopener"
        aria-label="Telegram"
      >
        <i class="fa-fw fab fa-telegram"></i>
      </a>
    

    <i
      id="copy-link"
      class="fa-fw fas fa-link small"
      data-bs-toggle="tooltip"
      data-bs-placement="top"
      title="Copy link"
      data-title-succeed="Link copied successfully!"
    >
    </i>
  </span>
</div>


  </div><!-- .post-tail-bottom -->

</div><!-- div.post-tail-wrapper -->


      
    
      
    </div>
  </div>
  <!-- #core-wrapper -->

  <!-- panel -->
  <div id="panel-wrapper" class="col-xl-3 ps-2 text-muted">
    <div class="access">
      <!-- Get the last 5 posts from lastmod list. -->














  <div id="access-lastmod" class="post">
    <div class="panel-heading">Recently Updated</div>
    <ul class="post-content list-unstyled ps-0 pb-1 ms-1 mt-2">
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/%E5%86%85%E5%AD%98%E6%95%B0%E6%8D%AE%E5%BA%93/">MMDB (memory database)</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/userspace-rcu%E9%94%81/">userspace rcu lock</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/Real-time-operating-system/">Realtime Operating System</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/HUNDSUN-LightOS/">Hundsun Lightos</a>
        </li>
      
        
        
        
        <li class="text-truncate lh-lg">
          <a href="/posts/linux-struct-folio/">struct folio</a>
        </li>
      
    </ul>
  </div>
  <!-- #access-lastmod -->


      <!-- The trending tags list -->















  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        



  <div id="access-tags">
    <div class="panel-heading">Trending Tags</div>
    <div class="d-flex flex-wrap mt-3 mb-1 me-3">
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/lock/">lock</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/libumem/">libumem</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/mm/">mm</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/autonuma/">autonuma</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bfs/">BFS</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bus/">Bus</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/caladan/">caladan</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/damon/">damon</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/deep-learning/">Deep Learning</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/dma/">DMA</a>
      
    </div>
  </div>


    </div>

    
      
      



  <div id="toc-wrapper" class="ps-0 pe-4 mb-5">
    <div class="panel-heading ps-3 pt-2 mb-2">Contents</div>
    <nav id="toc"><ul><li>High Performance OS - shanango<ul><li><a href="#一论序">一、论序</a></li><li><a href="#二shenango">二、shenango</a></li><li><a href="#三-数据中心应用特性">三、 数据中心应用特性</a><ul><li><a href="#1what-is-datacenter-workloads">1、what is Datacenter workloads?</a></li></ul></li><li><a href="#四代码分析">四、代码分析</a><ul><li><a href="#1iokernel">1、iokernel</a></li><li><a href="#2runtime">2、runtime</a></li><li><a href="#3iokernel和runtime联系--af_unix-socket">3、iokernel和runtime联系 – AF_UNIX socket</a></li></ul></li><li><a href="#五总结">五、总结</a></li><li><a href="#other补充">other、补充</a><ul><li><a href="#1go-runtime">1、go runtime</a></li><li><a href="#2dpdk">2、dpdk</a></li><li><a href="#3arachne">3、Arachne</a></li><li><a href="#4gc-garbage-collection">4、gc Garbage Collection</a></li></ul></li></ul></li></ul></li></ul></nav>
  </div>
  


    
  </div>
</div>

<!-- tail -->

  <div class="row">
    <div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 px-3 pe-xl-4 mt-5">
      
        
        <!--
  Recommend the other 3 posts according to the tags and categories of the current post,
  if the number is not enough, use the other latest posts to supplement.
-->

<!-- The total size of related posts -->


<!-- An random integer that bigger than 0 -->


<!-- Equals to TAG_SCORE / {max_categories_hierarchy} -->








  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  
    
  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  






<!-- Fill with the other newlest posts -->





  <div id="related-posts" class="mb-2 mb-sm-4">
    <h3 class="pt-2 mb-4 ms-1" data-toc-skip>
      Further Reading
    </h3>
    <div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4 mb-4">
      
        
        
        <div class="col">
          <a href="/posts/linux-kcsan/" class="card post-preview h-100">
            <div class="card-body">
              <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class="small"
  data-ts="1599782400"
  data-df="ll"
  
>
  Sep 11, 2020
</em>

              <h4 class="pt-0 my-2" data-toc-skip>The Kernel Concurrency Sanitizer (KCSAN)</h4>
              <div class="text-muted small">
                <p>
                  





                  1 kcasan

2 使用

                </p>
              </div>
            </div>
          </a>
        </div>
      
        
        
        <div class="col">
          <a href="/posts/linux-kprobe/" class="card post-preview h-100">
            <div class="card-body">
              <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class="small"
  data-ts="1600041600"
  data-df="ll"
  
>
  Sep 14, 2020
</em>

              <h4 class="pt-0 my-2" data-toc-skip>Kernel Probe (kprobe)</h4>
              <div class="text-muted small">
                <p>
                  





                  1 kprobe

2 debugfs kprobe trace
kprobe trace 使用debugfs的trace功能
 p[:[GRP/]EVENT] [MOD:]SYM[+offs]|MEMADDR [FETCHARGS]  : Set a probe
 r[MAXACTIVE][:[GRP/]EVENT] [MOD:]SYM[+0] [FETCHARGS]  : Set a r...
                </p>
              </div>
            </div>
          </a>
        </div>
      
        
        
        <div class="col">
          <a href="/posts/linux-userfaultfd/" class="card post-preview h-100">
            <div class="card-body">
              <!--
  Date format snippet
  See: ${JS_ROOT}/utils/locale-dateime.js
-->





<em
  class="small"
  data-ts="1600905600"
  data-df="ll"
  
>
  Sep 24, 2020
</em>

              <h4 class="pt-0 my-2" data-toc-skip>Kernel userfaultfd</h4>
              <div class="text-muted small">
                <p>
                  





                  Userfault只支持匿名页，hugetlb、共享内存；

一、软件流程

1 初始化
调用__NR_userfaultfd syscall初始化
调用syscall初始化建立匿名inode文件，并初始化file-&amp;gt;private_data,并返回用户态文件fd。


  
    用户态：

    uffd = syscall(__NR_userfaultfd, O_CLOEXE...
                </p>
              </div>
            </div>
          </a>
        </div>
      
    </div>
    <!-- .card-deck -->
  </div>
  <!-- #related-posts -->


      
        
        <!-- Navigation buttons at the bottom of the post. -->

<div class="post-navigation d-flex justify-content-between">
  
    <a
      href="/posts/Intel-HPC-mOS/"
      class="btn btn-outline-primary"
      prompt="Older"
    >
      <p>High Performance OS - Intel HPC kernel mOS</p>
    </a>
  

  
    <a
      href="/posts/linux-hugepages/"
      class="btn btn-outline-primary"
      prompt="Newer"
    >
      <p>HugePages</p>
    </a>
  
</div>

      
        
        <!--  The comments switcher -->


      
    </div>
  </div>


        <!-- The Search results -->

<div id="search-result-wrapper" class="d-flex justify-content-center unloaded">
  <div class="col-11 post-content">
    <div id="search-hints">
      <!-- The trending tags list -->















  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        

  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
    
  
    
    
    
    
      
        
        



  <div id="access-tags">
    <div class="panel-heading">Trending Tags</div>
    <div class="d-flex flex-wrap mt-3 mb-1 me-3">
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/lock/">lock</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/libumem/">libumem</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/mm/">mm</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/autonuma/">autonuma</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bfs/">BFS</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/bus/">Bus</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/caladan/">caladan</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/damon/">damon</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/deep-learning/">Deep Learning</a>
      
        
        <a class="post-tag btn btn-outline-primary" href="/tags/dma/">DMA</a>
      
    </div>
  </div>


    </div>
    <div id="search-results" class="d-flex flex-wrap justify-content-center text-muted mt-3"></div>
  </div>
</div>

      </div>
    </div>

    <!-- The Footer -->

<footer>
  <div class="container px-lg-4">
    <div class="d-flex justify-content-center align-items-center text-muted mx-md-3">
      <p>Using the <a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a> theme <a href="https://github.com/cotes2020/jekyll-theme-chirpy" target="_blank" rel="noopener">Chirpy</a>
      </p>

      <p>©
        2023
        <a href="https://gitee.com/luochenglcs">luochunsheng</a>.
        
          <span
            data-bs-toggle="tooltip"
            data-bs-placement="top"
            title="Except where otherwise noted, the blog posts on this site are licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) License by the author."
          >Some rights reserved.</span>
        
      </p>
    </div>
  </div>
</footer>


    <div id="mask"></div>

    <button id="back-to-top" aria-label="back-to-top" class="btn btn-lg btn-box-shadow">
      <i class="fas fa-angle-up"></i>
    </button>

    
      <div
        id="notification"
        class="toast"
        role="alert"
        aria-live="assertive"
        aria-atomic="true"
        data-bs-animation="true"
        data-bs-autohide="false"
      >
        <div class="toast-header">
          <button
            type="button"
            class="btn-close ms-auto"
            data-bs-dismiss="toast"
            aria-label="Close"
          ></button>
        </div>
        <div class="toast-body text-center pt-0">
          <p class="px-2 mb-3">A new version of content is available.</p>
          <button type="button" class="btn btn-primary" aria-label="Update">
            Update
          </button>
        </div>
      </div>
    

    <!-- JS selector for site. -->

<!-- commons -->



<!-- layout specified -->


  

  
    <!-- image lazy-loading & popup & clipboard -->
    
  















  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  

  
    

    

  



  <script src="https://cdn.jsdelivr.net/combine/npm/jquery@3.7.0/dist/jquery.min.js,npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js,npm/simple-jekyll-search@1.10.0/dest/simple-jekyll-search.min.js,npm/lazysizes@5.3.2/lazysizes.min.js,npm/magnific-popup@1.1.0/dist/jquery.magnific-popup.min.js,npm/clipboard@2.0.11/dist/clipboard.min.js,npm/dayjs@1.11.7/dayjs.min.js,npm/dayjs@1.11.7/locale/en.min.js,npm/dayjs@1.11.7/plugin/relativeTime.min.js,npm/dayjs@1.11.7/plugin/localizedFormat.min.js,npm/tocbot@4.21.0/dist/tocbot.min.js"></script>






<script defer src="/assets/js/dist/post.min.js"></script>






    

    <!--
  Jekyll Simple Search loader
  See: <https://github.com/christian-fei/Simple-Jekyll-Search>
-->





<script>
  /* Note: dependent library will be loaded in `js-selector.html` */
  SimpleJekyllSearch({
    searchInput: document.getElementById('search-input'),
    resultsContainer: document.getElementById('search-results'),
    json: '/assets/js/data/search.json',
    searchResultTemplate: '<div class="px-1 px-sm-2 px-lg-4 px-xl-0">  <a href="{url}">{title}</a>  <div class="post-meta d-flex flex-column flex-sm-row text-muted mt-1 mb-1">    {categories}    {tags}  </div>  <p>{snippet}</p></div>',
    noResultsText: '<p class="mt-5"></p>',
    templateMiddleware: function(prop, value, template) {
      if (prop === 'categories') {
        if (value === '') {
          return `${value}`;
        } else {
          return `<div class="me-sm-4"><i class="far fa-folder fa-fw"></i>${value}</div>`;
        }
      }

      if (prop === 'tags') {
        if (value === '') {
          return `${value}`;
        } else {
          return `<div><i class="fa fa-tag fa-fw"></i>${value}</div>`;
        }
      }
    }
  });
</script>

  </body>
</html>

